1921E - Eat the Chip - CodeForces Solution


brute force games

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fastio()                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(__null);
using namespace std;

void sol()
{
    int n, m;
    cin >> n >> m;
    
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    if (x1 > x2) {
        cout << "DRAW" << endl;
        return;
    }
    
    if ((x2 - x1) % 2 == 1) {
        int left1 = max(1ll, y1 - ((x2 - x1) / 2) - 1);
        int right1 = min(m, y1 + ((x2 - x1) / 2) + 1);
        int left2 = max(1ll, y2 - ((x2 - x1) / 2));
        int right2 = min(m, y2 + ((x2 - x1) / 2));
        
        if (right1 >= right2 && left1 <= left2) {
            cout << "Alice" << endl;
        }
        else {
            cout << "Draw" << endl;
        }
    }
    else {
        int left2 = max(1ll, y2 - ((x2 - x1) / 2));
        int right2 = min(m, y2 + ((x2 - x1) / 2));
        int left1 = max(1ll, y1 - ((x2 - x1) / 2));
        int right1 = min(m, y1 + ((x2 - x1) / 2));
        
        if (right1 <= right2 && left1 >= left2) {
            cout << "Bob" << endl;
        }
        else {
            cout << "Draw" << endl;
        }
    }
    
}

signed main()
{
    fastio()

        int k;
    k = 1;
    cin >> k;
    while (k--)
        sol();
    return 0;
}


Comments

Submit
0 Comments
More Questions

1450A - Avoid Trygub
327A - Flipping Game
411A - Password Check
1520C - Not Adjacent Matrix
1538B - Friends and Candies
580A - Kefa and First Steps
1038B - Non-Coprime Partition
43A - Football
50A - Domino piling
479A - Expression
1480A - Yet Another String Game
1216C - White Sheet
1648A - Weird Sum
427A - Police Recruits
535A - Tavas and Nafas
581A - Vasya the Hipster
1537B - Bad Boy
1406B - Maximum Product
507B - Amr and Pins
379A - New Year Candles
1154A - Restoring Three Numbers
750A - New Year and Hurry
705A - Hulk
492B - Vanya and Lanterns
1374C - Move Brackets
1476A - K-divisible Sum
1333A - Little Artem
432D - Prefixes and Suffixes
486A - Calculating Function
1373B - 01 Game